package pl.polsl.mmm.projectcomm.programs;

import pl.polsl.mmm.projectcomm.util.ShaderHelper;
import pl.polsl.mmm.projectcomm.util.TextResourceReader;

import static android.opengl.GLES20.glUseProgram;
import android.content.Context;

public class ShaderProgram {
	//uniform constants
	protected static final String U_MATRIX = "u_Matrix";
    protected static final String U_VIEW_MATRIX = "u_ViewMatrix";
	protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
	
	//attribute constants
	protected static final String A_POSITION = "a_Position";
	//protected static final String A_COLOR = "a_Color";
	protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
	protected static final String A_NORMAL = "a_Normal";

	protected static final String U_COLOR = "u_Color";

    //światło
    protected static final String U_LIGHT_POSITION = "u_LightPos";
    protected static final String U_LIGHT_AMBIENT = "u_LightAmb";
    protected static final String U_LIGHT_DIFFUSE = "u_LightDiff";
    protected static final String U_LIGHT_SPECULAR = "u_LightSpec";

	//shader program
	protected final int program;
	protected ShaderProgram(Context context, int vertexShaderResourceId,int fragmentShaderRecourceId) {
		
		program = ShaderHelper.buildProgram(
				TextResourceReader.readTextFileFromResource(
						context, vertexShaderResourceId),
				TextResourceReader.readTextFileFromResource(
						context, fragmentShaderRecourceId));
		
	}
	public void useProgram() {
		//set the current openGL shader program to this program
		glUseProgram(program);
	}
	
}
